package com.woniu.cms.goods.core.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniu.cms.goods.core.entity.GoodsReturnMaterial;
import com.woniu.cms.goods.core.mapper.GoodsReturnMaterialMapper;
import com.woniu.cms.goods.core.service.IGoodsReturnMaterialService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.cms.goods.core.service.IGoodsReturnService;
import com.woniu.cms.goods.core.vo.OutbillVo;
import com.woniu.cms.goods.core.vo.ReturnVo;
import com.woniu.common.api.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 退料单附属材料表，退料单材料详情页所显示的信息 服务实现类
 * </p>
 *
 * @author romantic sheep
 * @since 2022-09-19
 */
@Service
public class GoodsReturnMaterialServiceImpl extends ServiceImpl<GoodsReturnMaterialMapper, GoodsReturnMaterial> implements IGoodsReturnMaterialService {

    @Autowired
    private GoodsReturnMaterialMapper returnMaterialMapper;
    @Autowired
    private IGoodsReturnService returnService;

    @Override
    public Result getList(Integer currentPage, Integer pageSize, Integer status) {
        List<ReturnVo> returnVos=returnMaterialMapper.getlist(status);
        PageInfo<ReturnVo> pageInfo = PageHelper.startPage(currentPage, pageSize).
                doSelectPageInfo(() -> returnMaterialMapper.getlist(status));
        List<ReturnVo> list = pageInfo.getList();
        long total = pageInfo.getTotal();
        Map map=new HashMap();
        map.put("data",list);
        map.put("total",total);
        Result<Map> common = Result.common(map);
        return common;
    }
}
